
segmentDuration = 1
frameDuration = 0.025
hopDuration = 0.010
numBands = 40
epsil = 1e-6

class Parameters:
    def __init__(self):
        self.SampleRate = 0
        self.WindowLength = 0
        self.HopLength = 0   
        self.NumBands = 0
        self.FFTLength = 0
        self.Range= [ 0,0 ]

        self.WarpType = 0     
        self.WindowType = 0

            
    def set_param(self,**kwargs):    

        if "SampleRate" in kwargs:
            fs = kwargs["SampleRate"]        
            self.SampleRate  = fs
 
        if "WindowLength" in kwargs:        
            win_length  = kwargs["WindowLength"]
    
            self.WindowLength = win_length    
 
        if "WindowLength" in kwargs:
            overlap_length= kwargs["OverlapLength"]
            hop_length = self.WindowLength - overlap_length
                                                         
            self.HopLength = hop_length
         

        if "NumBands" in kwargs:
            num_bands   = kwargs["NumBands"]        
                                        
            self.NumBands = num_bands
         

        if "FFTLength" in kwargs:
            fft_length  = kwargs["FFTLength"]        

            self.FFTLength = fft_length
         
        if "Range" in kwargs: 
            freq_range = kwargs["Range"]

            self.Range = freq_range
 
                        
        
        dict_warp_type={
            "mel" : 1,
            "erb" : 2,
            "bark": 3	
        }
            	        
        if "WarpType" in kwargs and kwargs["WarpType"] in dict_warp_type:
            warp_type = dict_warp_type[kwargs["WarpType"]]

            self.WarpType = warp_type 
 
                        
        dict_win_type={
             "hann" : 1,
             "hamming" : 2
        }        
                
        if "WindowType" in kwargs and kwargs["WindowType"] in dict_win_type:        
             win_type = dict_win_type[kwargs["WindowType"]]
             self.WindowType = win_type 
 
    def set_frame_param(self,nSampleRate):
        frameLength = round(frameDuration*nSampleRate);
        hopLength = round(hopDuration*nSampleRate);    	
        self.SampleRate = int(nSampleRate)
        self.WindowLength = int(frameLength)
        self.HopLength = int(hopLength)      	
